/*************************************************************************
 *
 * $Id: menu.h 32 2006-06-30 15:46:46Z alpov $
 * 
 *************************************************************************/         

#ifndef _MENU_H
#define _MENU_H

#define MENU_REFRESH    -1
#define MENU_MESSAGE    -2

#ifndef _MENU_C
AVRX_EXT_FIFO(MenuFifo);
#endif

AVRX_EXTERNTASK(MenuTask);
extern void InitMenuTask(void);

#define BeginEditing()  { AvrXWaitSemaphore(&DataLock); }
#define EndEditing()    { AvrXSetSemaphore(&DataLock); /* SendData(); */ }
#define CancelEditing() { AvrXSetSemaphore(&DataLock); /* RequeryData(); */ }

#define ST_MAIN             10
#define ST_SHIFT            20
#define ST_SHIFT_EDIT       21
#define ST_MODE             30
#define ST_MODE_EDIT        31
#define ST_RTC              40
#define ST_RTC_EDIT         41
#define ST_SWITCH           50
#define ST_SWITCH_EDIT_M    51
#define ST_SWITCH_EDIT_C    52
#define ST_CONFIG           100
#define ST_CONFIG_EDIT      101
#define ST_MESSAGE          200
#define ST_ERROR            255

extern unsigned char MenuChangeSensor(unsigned char key, unsigned char state);
extern unsigned char MenuChangeValue(unsigned char key, unsigned char state);
extern unsigned char MenuChangeClock(unsigned char key, unsigned char state);

extern unsigned char MenuEditShift(unsigned char key, unsigned char state);
extern unsigned char MenuEditMode(unsigned char key, unsigned char state);
extern unsigned char MenuEditRtc(unsigned char key, unsigned char state);
extern unsigned char MenuEditSwitch(unsigned char key, unsigned char state);
extern unsigned char MenuEditConfig(unsigned char key, unsigned char state);

#endif
